/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bs.global.modelo;

import bs.stock.modelo.Deposito;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Claudio
 */
@Entity
@Table(name = "gr_comprobante")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "MODCOM", discriminatorType = DiscriminatorType.STRING, length = 2)
public class Comprobante implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ComprobantePK idPK;
    @Basic(optional = false)

    @Column(name = "MODCOM",nullable = false, insertable=false, updatable=false, length = 2)
    private String modulo;

    @Column(name = "CODCOM", nullable = false, insertable=false, updatable=false, length = 6)
    private String codigo;

    @Column(name = "DESCRP", nullable = false, length = 60)
    private String descripcion;
    
    @Column(name = "TITULO", length = 60)
    private String titulo;

    @Column(name = "TIPREG", length = 1)
    private String tipreg;
    
    @Column(name = "COPIAS")
    private Short copias;    
    @Column(name = "RECFEC", length = 1)
    private String recfec;
        
    /**
     * Deposito emisor
     */
    @JoinColumn(name = "DEPEGR", referencedColumnName = "CODIGO",nullable = true)
    @ManyToOne(fetch = FetchType.LAZY)
    private Deposito depositoEgreso;

        /**
     * Deposito receptor
     */
    @JoinColumn(name = "DEPING", referencedColumnName = "CODIGO",nullable = true)
    @ManyToOne(fetch = FetchType.LAZY)
    private Deposito depositoIngreso;

    @Lob
    @Column(name = "TEXTOS", length = 2147483647)
    private String textos;
    
    /**
    @Column(name = "CGMASCAR", length = 6)
    private String cgmascar;
    @Column(name = "CGSUBDIA", length = 1)
    private String cgsubdia;
    @Column(name = "CGTIPMOV", length = 1)
    private String cgtipmov;
    @Column(name = "CODDIM", length = 6)
    private String coddim;
    @Column(name = "CONDIA", length = 1)
    private String condia;         
    @Column(name = "CFTIPESM", length = 1)
    private String cftipesm;    
    @Column(name = "CGDIMUNI", length = 1)
    private String cgdimuni; 
    @Column(name = "SJDIMUNI", length = 1)
    private String sjdimuni;
    @Column(name = "CVTIPCOM", length = 1)
    private String cvtipcom;
    @Column(name = "CBCTACTE", length = 6)
    private String cbctacte;    
    @Column(name = "HSERIE", length = 1)
    private String hserie;
    @Column(name = "HDESPA", length = 1)
    private String hdespa;
    @Column(name = "HOTROS", length = 1)
    private String hotros;
    @Column(name = "HENVAS", length = 1)
    private String henvas;
    @Column(name = "HFECHA", length = 1)
    private String hfecha;
    @Column(name = "HATRIB", length = 1)
    private String hatrib;
    @Column(name = "HESTAN", length = 1)
    private String hestan;
    @Column(name = "HUBICA", length = 1)
    private String hubica;
    @Column(name = "CFVENC", length = 1)
    private String cfvenc;
    @Column(name = "PDNROINT", length = 1)
    private String pdnroint;
    @Column(name = "SJTIPCOM", length = 1)
    private String sjtipcom;
    @Column(name = "SJCODCPT", length = 6)
    private String sjcodcpt;
    @Column(name = "GCFCHMOV", length = 1)
    private String gcfchmov;
        
    @Column(name = "CGCOFLIS", length = 6)
    private String cgcoflis;
    @Column(name = "CGEDIMON", length = 1)
    private String cgedimon;
    @Column(name = "TIPCOM", length = 1)
    private String tipcom;
    @Column(name = "MULFRM", length = 1)
    private String mulfrm;
    @Column(name = "DEFSTD", length = 1)
    private String defstd;
    @Column(name = "TRAFCR", length = 1)
    private String trafcr;
    @Column(name = "MODCDV", length = 2)
    private String modcdv;
    @Column(name = "CODCDV", length = 6)
    private String codcdv;
    
    
    
    @Column(name = "CVMASCAR", length = 6)
    private String cvmascar;
    
    @Column(name = "CBINFCHE", length = 1)
    private String cbinfche;
    
    @Column(name = "LECTOR", length = 6)
    private String lector;
    
    
    @Column(name = "SUBCUE", length = 40)
    private String subcue;
    
    @Column(name = "REPPRE", length = 15)
    private String reppre;
    @Column(name = "NORECI", length = 1)
    private String noreci;
    
    
    @Column(name = "HORMOV", length = 10)
    private String hormov;
    @Column(name = "MODULE", length = 10)
    private String module;
    
    @Column(name = "LOTTRA", length = 6)
    private String lottra;
    @Column(name = "LOTREC", length = 6)
    private String lotrec;
    @Column(name = "LOTORI", length = 6)
    private String lotori;
    @Column(name = "SYSVER", length = 10)
    private String sysver;
    @Column(name = "CMPVER", length = 10)
    private String cmpver;
    @Column(name = "PERSON", length = 1)
    private String person;
    @Column(name = "MODNUM", length = 1)
    private String modnum;
    @Column(name = "MODFEC", length = 1)
    private String modfec;
    @Column(name = "SECNUM", length = 1)
    private String secnum;
    @Column(name = "SECFEC", length = 1)
    private String secfec;
    @Column(name = "REPECE", length = 1)
    private String repece;
    */
    

    @Embedded
    private Auditoria auditoria;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "comprobante", fetch=FetchType.LAZY)
    private List<FormularioPorSituacionIVA> formulariosPorSituacionIVA;

    public Comprobante() {
    }

    public Comprobante(ComprobantePK gR_ComprobantePK) {
        this.idPK = gR_ComprobantePK;
    }

    public Comprobante(ComprobantePK gR_ComprobantePK, String Descrp) {
        this.idPK = gR_ComprobantePK;
        this.descripcion = Descrp;
    }

    public Comprobante(String Modcom, String Codcom) {
        this.idPK = new ComprobantePK(Modcom, Codcom);
    }

    public ComprobantePK getIdPK() {
        return idPK;
    }

    public void setIdPK(ComprobantePK idPK) {
        this.idPK = idPK;
    }

    public String getModulo() {
        return modulo;
    }

    public void setModulo(String modulo) {
        this.modulo = modulo;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public String getTipreg() {
        return tipreg;
    }

    public void setTipreg(String tipreg) {
        this.tipreg = tipreg;
    }

    public Short getCopias() {
        return copias;
    }

    public void setCopias(Short copias) {
        this.copias = copias;
    }

    public String getRecfec() {
        return recfec;
    }

    public void setRecfec(String recfec) {
        this.recfec = recfec;
    }

    public Deposito getDepositoEgreso() {
        return depositoEgreso;
    }

    public void setDepositoEgreso(Deposito depositoEgreso) {
        this.depositoEgreso = depositoEgreso;
    }

    public Deposito getDepositoIngreso() {
        return depositoIngreso;
    }

    public void setDepositoIngreso(Deposito depositoIngreso) {
        this.depositoIngreso = depositoIngreso;
    }

    public String getTextos() {
        return textos;
    }

    public void setTextos(String textos) {
        this.textos = textos;
    }

    public Auditoria getAuditoria() {
        return auditoria;
    }

    public void setAuditoria(Auditoria auditoria) {
        this.auditoria = auditoria;
    }

    public List<FormularioPorSituacionIVA> getFormulariosPorSituacionIVA() {
        return formulariosPorSituacionIVA;
    }

    public void setFormulariosPorSituacionIVA(List<FormularioPorSituacionIVA> formulariosPorSituacionIVA) {
        this.formulariosPorSituacionIVA = formulariosPorSituacionIVA;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPK != null ? idPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Comprobante)) {
            return false;
        }
        Comprobante other = (Comprobante) object;
        if ((this.idPK == null && other.idPK != null) || (this.idPK != null && !this.idPK.equals(other.idPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Comprobante{" + "idPK=" + idPK + '}';
    }


}
